<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="xm"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/base.css">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/index.css">
<script type="text/javascript">
	function finderMer(id){
		location.href='<%=request.getContextPath()%>/merchandise?m=findMerById&id='+id;
		}
	function findMerListBySpe(special){
		location.href='<%=request.getContextPath()%>/merchandise?m=findMerListBySpe&special='+special;

	}
	function doLogin(){
		var loginName = document.getElementById("loginName").value;
		var loginPwd = document.getElementById("loginPwd").value;
		if(loginName=='' || loginPwd==''){
			alert("用户名和密码不能为空");
			return;
		}	
		location.href='<%=request.getContextPath()%>/member?m=login&loginName='+loginName+"&loginPwd="+loginPwd;
	}
	function userExit(){
		location.href='<%=request.getContextPath()%>/member?m=exit';	
	}
	function addCart(merId,price,sprice){
		//alert(merId+','+price+','+sprice);
		//调用控制器去执行加入购物车
		location.href='<%=request.getContextPath()%>/filter/cart?m=add&merId='+merId+'&price='+price+'&sprice='+sprice;
	}
	function doRegister(){
		location.href='<%=request.getContextPath()%>/html/memberRegister.jsp';
	}
	function findMerListByCateKey2(cateKey){

		var nameKey = "pass";
		alert(cateKey);
		location.href='<%=request.getContextPath()%>/merchandise?m=findMerListByCateKeyAndNameKey&nameKey='+nameKey+"&cateKey="+cateKey;
		
	}
</script>
</head>
<body>
	 <div id="box">
		<jsp:include page="/comm/header.jsp"></jsp:include>
		 <div id="main">
		 	<div id="indexInfo">
		 		<div id="leftArea">
		 			<div class="memberDiv">
				 		<xm:if test="${memberInfo eq null }">
	                      
	                      <h4>会员登录</h4>
		                  <p>登录账号：<input id="loginName">
		                  </p>
		                  <p>登录密码：<input type="password" id="loginPwd">
		                  </p>
		                  <p>
		                      <button class="regButton" title="注册账号" onclick="doRegister()">注册</button>
		                      <button class="loginButton" title="登录按钮" onclick="doLogin()">登录</button>
		                  </p>
		                  <p align="center"><font color="red">${message }</font></p>
                 		</xm:if>
                 		<xm:if test="${memberInfo ne null}">
		                      <h4>会员信息</h4>
			                  <p align="center">会员级别：${memberInfo.levelName}
			                  </p>
			                  <p align="center">会员名称：${memberInfo.memberName}
			                  </p>
			                  <p align="center">
			                      <button class="regButton" onclick="userExit()" title="确认安全退出"> 安全退出</button>
			                  </p>
                 		</xm:if>
		 			</div>
		 			<div class="merTypeDiv">
		 				<h4>商品类别</h4>
		 				<ul>
		 				<xm:forEach items="${cateList }" var="cate">
		 				
		 				<li><a href="#"  onclick="findMerListByCateKey2(${cate.id })">${cate.cateName}</a> </li>
                        <input type="hidden" id="cateKey2" value=""/>
		 				</xm:forEach>
		 				 	
		 				</ul>
		 				
		 			</div>
		 		</div>
		 		<div id="rightArea">
		 			<div class="merShowArea">
		 				<div class="logoDiv">
		 					<img alt="" src="images/Icon_TeJia.gif" class="leftImg">
		 					<img alt="" src="images/more4.gif" title="查看更多特价商品" class="moreImg" onclick="findMerListBySpe(1)">
		 				</div>
		 				<div class="jiangeDiv"></div>
		 				<div class="merListDiv">
		 					<xm:forEach items="${specialMerList }" var="mer" begin="0" end="2">
			 					<div class="merDiv">
			 						<img alt="" src="<%=request.getContextPath() %>${mer.picture }" class="merImg">
			 						<br>
			 						<a href="#${mer.id}"> ${mer.merName }</a>
			 						<br>
			 						市场价:${mer.price }<br>
			 						特价:${mer.sprice }<br>
			 						<img alt="" src="images/icon_car12.gif" title="查看此商品详情" class="mar_Top" onclick="finderMer(${mer.id})">
			 						<img alt="" src="images/icon_buy14.gif" title="加入购物车" onclick="addCart(${mer.id},${mer.price },${mer.sprice })">
			 					</div>
		 					</xm:forEach>
		 					
		 					
		 				</div>
		 			</div>
		 			<!-- --- -->
		 			<div class="merShowArea">
		 				<div class="logoDiv">
		 					<img alt="" src="images/NewGoods_03.gif" class="leftImg">
		 					<img alt="" src="images/more4.gif" title="查看更多新上市商品" class="moreImg" onclick="findMerListBySpe(0)">
		 				</div>
		 				<div class="jiangeDiv"></div>
		 				<div class="merListDiv">
		 					<xm:forEach items="${newMerList }" var="mer" begin="0" end="2">
			 					<div class="merDiv">
			 						<img alt="" src="<%=request.getContextPath() %>${mer.picture }" class="merImg">
			 						<br>
			 						<a href="#${mer.id}"> ${mer.merName }</a>
			 						<br>
			 						市场价:${mer.price }<br>
			 						<img alt="" src="images/icon_car12.gif" title="查看此商品详情" class="mar_Top" onclick="finderMer(${mer.id})">
			 						<img alt="" src="images/icon_buy14.gif"  title="加入购物车" onclick="addCart(${mer.id},${mer.price },${mer.sprice })">
			 					</div>
		 					</xm:forEach>
		 				</div>
		 			</div>
		 		</div>
		 	</div>
		 </div>
		 <jsp:include page="/comm/footer.jsp"></jsp:include>
	 </div>
</body>
</html>